home *** CD-ROM | disk | FTP | other *** search
/ DarkBASIC - The Ultimate 3D Game Creator / PCactive 8 CD1 - DarkBasic.iso / SOFTWARE / DEMOS / DarkForge2000 / snippets_vol1 / snip_precalc_scroller.dba < prev    next >
Encoding:
Text File  |  2000-08-05  |  978 b   |  54 lines

  1. `    ------------------------------------------------------------------------
  2. `    Pre-Calculated Scroller                     DarkForge Snippet (6/8/2000)
  3. `    ------------------------------------------------------------------------
  4. `
  5. `    In the days of old we had to pre-calculate everything. In this example
  6. `    I show you how to achieve a smooth and fast full-screen scroller using
  7. `    only sprites that never change position.
  8.  
  9. sync rate 0
  10. sync on
  11. hide mouse
  12.  
  13. load image "bubble.bmp",1
  14.  
  15. `    Change this value from 2 to 32!
  16. speed=8
  17.  
  18. `    Pre-calculate the sprites
  19.  
  20. offset#=-128
  21.  
  22. for i=1 to 129
  23.     paste image 1,offset#+i,0
  24.     paste image 1,offset#+64+i,0
  25.     paste image 1,offset#+128+i,0
  26.     get image i+1,0,0,64,64
  27.     sprite i,-256,0,i
  28.     set sprite i,0,1
  29. next i
  30.  
  31. spr=2 : i=1
  32.  
  33. do
  34.  
  35.     cls 0
  36.  
  37.     for y=0 to 480 step 64
  38.  
  39.         for x=0 to 640 step 64
  40.             sprite i,x,y,spr
  41.             inc i
  42.         next x
  43.  
  44.     next y
  45.  
  46.     spr=spr+speed
  47.     if spr>129 then spr=2
  48.     i=1 : inc d,2
  49.  
  50.     sync
  51.  
  52. loop
  53.  
  54.